#include "stdio.h"
//#include "windows.h"
//#include <list>
//#include "FSElement.h"
#include "MyPanel.h"

// using namespace System::Runtime::InteropServices;
// using namespace System;
using namespace std;

/*
char* StringToChar (String^ str)
{
	return (char*)(void*)Marshal::StringToHGlobalAnsi(str);
}*/

/*
list<FSElement> Dir(String^ root)
{
	list<FSElement> ElemList;
	
	WIN32_FIND_DATA fd;
	//char root[260];
	//strcat(root,"\\*");
	//strcpy(root,root2);
	//strcat(root,"\\*");
	HANDLE hFind=::FindFirstFile(StringToChar(root->Concat("\\*")), &fd);
//	HANDLE hFind=::FindFirstFile(root, &fd);
	//HANDLE hFind=::FindFirstFile(L"d:\\*", &fd);
	if(hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			char temp [255];
			sprintf(temp,"%s\n", fd.cFileName);
			//printf("%s: %s\n", (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? "Folder" : "File", fd.cFileName);
			ElemList.push_back(FSElement(temp, fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));

		} while(::FindNextFile(hFind, &fd));

		::FindClose(hFind);
	}
	return ElemList;
}*/

void printList(list<FSElement> ElemList)
{
	for (list<FSElement>::iterator i = ElemList.begin(); i!=ElemList.end(); ++i)
	{
		printf("%s: %s\n", ((*i).isFolder) ? "Folder" : "File",(*i).name);
	}}


int main()
{

	MyPanel abc;
	abc.setDirectory("D:");
	printList(abc.Elements);
	char c[255];
	while (scanf("%s", c)) 
	{
		printf("-------------------------------------------------");
		if (c[0]=='1')
		{
			abc.appendDirectory("123");
			//currentDir->Concat("\\123");
		}
		if (c[0]=='n') //next
		{
			abc.goNext();
			printf("Now you on %s\n", (*abc.currentElem).name);
			//currentDir->Concat("\\123");
		}
		if (c[0]=='p') //prev
		{
			abc.goPrev();
			printf("Now you on %s\n", (*abc.currentElem).name);
			//currentDir->Concat("\\123");
		}
		if (c[0]=='e') //enter
		{
			abc.enter();
			printf("Now you in %s\n", (*abc.currentElem).name);
			//currentDir->Concat("\\123");
		}
		if (c[0]=='q') //
		{
			abc.setDirectory("D:\\123");
			//currentDir->Concat("\\123");
		}
		printList(abc.Elements);
	} 


 	return 0;
}